home *** CD-ROM | disk | FTP | other *** search
/ Complete Linux / Complete Linux.iso / docs / devel / ada / adaed_1_.z / adaed_1_ / Adaed-1.11.0a / axqw.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-02-07  |  2.9 KB  |  117 lines

  1. /*
  2.  * Copyright (C) 1985-1992  New York University
  3.  * 
  4.  * This file is part of the Ada/Ed-C system.  See the Ada/Ed README file for
  5.  * warranty (none) and distribution info and also the GNU General Public
  6.  * License for more details.
  7.  
  8.  */
  9. /* axqw.c - axq output procedures */
  10.  
  11. #define GEN
  12.  
  13. #include "hdr.h"
  14. #include "vars.h"
  15. #include "segment.h"
  16. #include "gvars.h"
  17. #include "slot.h"
  18. #include "ifile.h"
  19. #include "setprots.h"
  20. #include "libfprots.h"
  21. #include "miscprots.h"
  22. #include "segmentprots.h"
  23. #include "axqwprots.h"
  24.  
  25. static void put_slot(IFILE *, Tuple);
  26.  
  27. void segment_write(IFILE *file, Segment seg)                /*;segment_write*/
  28. {
  29.     short    dim;
  30.  
  31.     seg_check(seg);
  32.     putnum(file, "segment-kind", seg->seg_kind);
  33.     dim = seg->seg_maxpos + 1;
  34.     putnum(file, "segment-dim", dim);
  35. #ifdef HI_LEVEL_IO
  36.     fwrite(seg->seg_data, seg->seg_size, dim, file->fh_file);
  37. #else
  38.     write(file->fh_file, seg->seg_data, seg->seg_size*dim);
  39. #endif
  40. }
  41.  
  42. void put_cde_slots(IFILE *file, int ifaxq)                    /*;put_cde_slots*/
  43. {
  44.     long    dpos;
  45.  
  46.     dpos = iftell(file); /* get current position */
  47.     putnum(file, "n-code_slots", tup_size(CODE_SLOTS));
  48.     putnum(file, "n-data-slots", tup_size(DATA_SLOTS));
  49.     putnum(file, "n-exception-slots", tup_size(EXCEPTION_SLOTS));
  50.     put_slot(file, CODE_SLOTS);
  51.     put_slot(file, DATA_SLOTS);
  52.     put_slot(file, EXCEPTION_SLOTS);
  53.     /* now replace word at start of  file with long giving offset to 
  54.      *start of information just written.
  55.      */
  56.     file->fh_slots = dpos;
  57.     ifclose(file);
  58. }
  59.  
  60. static void put_slot(IFILE *file, Tuple tup)                    /*;put_slot*/
  61. {
  62.     /* This procedure writes out the SLOTS information. These are maps from
  63.      * symbols to unit names. The interpreter needs only to know the names
  64.      * of the symbols so we write their names if available, else
  65.      * an empty string.
  66.      */
  67.  
  68.     int i, n;
  69.     Slot slot;
  70.  
  71.     n = tup_size(tup);
  72.     putnum(file, "slot-entries", n);
  73.     for (i = 1; i <= n; i++) {
  74.         slot = (Slot) tup[i];
  75.         if (slot == (Slot)0) {
  76.             if (compiling_predef)
  77.                 chaos("undefined slot compiling predef");
  78.             putnum(file, "slot-exists", 0);
  79.         }
  80.         else {
  81.             putnum(file, "slot-exists", 1);
  82.             putnum(file, "slot-seq", slot->slot_seq);
  83.             putnum(file, "slot-unit", slot->slot_unit);
  84.             putnum(file, "slot-number", slot->slot_number);
  85.             putstr(file, "slot-name", slot->slot_name);
  86.         }
  87.     }
  88. }
  89.  
  90. void predef_exceptions(Tuple tup)                    /*;predef_exceptions*/
  91. {
  92.     /* This procedure writes out the SLOTS information.
  93.      * This variant of put_slot writes out definitions of predefined exceptions
  94.      * when compiling predef, in a form suitable for inclusion as the body
  95.      * of init_predef_exceptions (cf. init.c).
  96.      */
  97.  
  98.     int i, n;
  99.     Slot slot;
  100.  
  101.     n = tup_size(tup);
  102.     printf("exception slots\n");
  103.     /* first five exceptions defined in standard */
  104.     for (i = 6; i <= n; i++) {
  105.         slot = (Slot) tup[i];
  106.         if (slot == (Slot)0) {
  107.             if (compiling_predef)
  108.                 chaos("undefined slot compiling predef");
  109.         }
  110.         else {
  111.             printf("    init_predef_exception(%d, %d, %d, \"%s\");\n",
  112.               slot->slot_seq, slot->slot_unit, slot->slot_number,
  113.               slot->slot_name);
  114.         }
  115.     }
  116. }
  117.